import request from '../utils/request';
import ajax from './ajax';

export const fetchData = query => {
    return request({
        url: './table.json',
        method: 'get',
        params: query
    });
};
export const mockLogData = query => {
    return request({
        url: './log.json',
        method: 'get',
        params: query
    });
};
export const mockParkingInfoData = () => {
    return request({
        url: './parkinginfo.json',
        method: 'get'
    });
};
export const mockRoadData = query => {
    return request({
        url: './road.json',
        method: 'get',
        params: query
    });
};

/**---------用户管理---------*/
/**管理员登录 */
export const login = ({username,password}) => ajax('/user/adminLogin',{userName:username,password},'POST');

/**修改用户 */
export const updateUser = ({userId,username,password,userRoleId,money}) => ajax('/user/update',{userId,username,password,userRoleId,money},'PUT');

/**查询用户 */
export const getUserList = ({userRoleId,username,pageIndex,pageSize}) => ajax('/user/selectByNameAndRole',{userRoleId,username,pageIndex,pageSize},'GET')

/**添加用户 */
export const addUser = ({username,password,userRoleId,money}) => ajax('/admin/save',{username,password,userRoleId,money},'GET');

/**删除用户*/
export const deleteUser = ({userId}) => ajax('/admin/delete',{userId},'GET')

/**---------停车位管理---------*/
/**查询所有停车位 */
export const getParkingList = ({manageArea,pageIndex,pageSize}) => ajax('/manage/listByArea',{manageArea,pageIndex,pageSize},'GET')

/**添加停车点*/
export const addParking = ({manageArea,manageDelete,managePs,manageStaId}) => ajax('/manage/save',{manageArea,manageDelete,managePs,manageStaId},'POST');

/**修改停车点*/
export const updateParking = ({id,manageArea,manageDelete,managePs,manageStaId}) => ajax('/manage/edit',{id,manageArea,manageDelete,managePs,manageStaId},'PUT');

/**禁用停车位 */
export const disableParking = ({id}) => ajax('/manage/disableSpots',{id},'GET');

/**启用停车位 */
export const enableParking = ({id}) => ajax('/manage/ensableSpots',{id},'GET');

/**---------路段管理---------*/
/**获取所有路段 */
export const getRoads = () => ajax('/road/getRoads',{},'GET');

/**删除路段 */
export const deleteRoad = ({roadId}) => ajax('/road/deleteRoad',{roadId},'POST');

/**添加路段 */
export const addRoad = ({roadName}) => ajax('/road/addRoad',{roadName},'POST');

/**修改路段 */
export const updateRoad = ({roadId,roadName}) => ajax('/road/updateRoad',{roadId,roadName},'POST');


/**---------停车记录管理---------*/
/**查询停车记录 */
export const getParkingLogs = ({recStatus,pageIndex,pageSize}) => ajax('/record/selectByStatus',{recStatus,pageIndex,pageSize},'GET');

/**删除停车记录 */
export const deleteParkingLog = ({recId}) => ajax('/record/delete',{recId},'GET');
